package com.woniuxy.juc.reentrant;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

/**
 * <P> @Author: ideaAdmin
 * <P> TODO: Class
 * <P> TODO: 可重入锁的多条件
 * <P> Date: 2022/4/8:8:48
 * <P> Description:
 */
@Slf4j(topic = "c.ReentrantLockTest4")
public class ReentrantLockTest4 {
    private static ReentrantLock lock = new ReentrantLock();
    public static void main(String[] args) {
        //TODO 创建一个新的条件变量(休息室)
        Condition condition1 = lock.newCondition();
        Condition condition2 = lock.newCondition();

        lock.lock();
        //进入休息室等待
        try {
            condition1.await();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //TODO 唤醒这个条件变量的一个线程
        condition1.signal();
        //TODO 唤醒这个条件变量的全部线程
        condition1.signalAll();
    }


}
